<template>
  <el-form :inline="true" class="demo-form-inline">
    <el-form-item label="projectName">
      <el-input v-model="projectName" placeholder="projectName"></el-input>
    </el-form-item>
    <el-form-item label="suitName">
      <el-select v-model="suiteName" placeholder="suitName">
        <el-option
          label="smokeAll"
          value="fantasyrn_api_smoke_test"
        ></el-option>
        <el-option label="flowAll" value="fantasyrn_flow"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="tag">
      <el-input v-model="tag" placeholder="tag"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">启动</el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts">
import { Start } from '@/api/auto.js'

export default {
  data() {
    return {
      suiteName: 'smokeAll',
      projectName: '',
      tag: '',
    }
  },
  methods: {
    onSubmit() {
      let params =
        '?suiteName=' +
        this.suiteName +
        '&projectName=' +
        this.projectName +
        '&revisionIDs=null&branchName=null&tag=' +
        this.tag
      Start(params)
        .then(res => {
          console.log('启动测试', res)
          if (res.code === 200 && res.success === true) {
            this.$message({
              type: 'success',
              message: '接口自动化启动成功！',
            })
          }
        })
        .catch(err => {
          console.log(err)
        })

      console.log('submit!')
    },
  },
}
</script>
